package com.duan.validator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/*自定义校验器*/
// 注解在哪些范围上生效，方法、属性...
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER })
@Retention(RUNTIME)
@Documented
//核心：告诉当前注解最后会选中哪个类去进行校验规则
@Constraint(validatedBy = {IsMobileValidator.class })
public @interface IsMobile {
    boolean required() default true;

    // 默认提示
    String message() default "手机号码格式错误";

    Class<?>[] groups() default { };

    Class<? extends Payload>[] payload() default { };

}
